package com.potenza.training.interview.controller;

import com.potenza.training.interview.entity.InterviewLogEntity;
import com.potenza.training.interview.service.InterviewLogService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;



/**
 * 
 *
 * @author lihonggang
 * @email lihonggang@gmail.com
 * @date 2021-08-02 21:19:17
 */
@RestController
@RequestMapping("interview/interviewlog")
public class InterviewLogController {
    @Autowired
    private InterviewLogService interviewLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("resume:interviewlog:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = interviewLogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("resume:interviewlog:info")
    public R info(@PathVariable("id") Integer id){
		InterviewLogEntity interviewLog = interviewLogService.getById(id);

        return R.ok().put("interviewLog", interviewLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("resume:interviewlog:save")
    public R save(@RequestBody InterviewLogEntity interviewLog){
		interviewLogService.save(interviewLog);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("resume:interviewlog:update")
    public R update(@RequestBody InterviewLogEntity interviewLog){
        interviewLogService.updateById(interviewLog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("resume:interviewlog:delete")
    public R delete(@RequestBody Integer[] ids){
		interviewLogService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    @RequestMapping("/findById/{id}")
    @RequiresPermissions("resume:interviewlog:findById")
    public R findById(@PathVariable Integer id){
        List<InterviewLogEntity>  list = interviewLogService.findById(id);

        return R.ok().put("list",list);
    }

    @RequestMapping("/findByinvitationId/{id}")
    @RequiresPermissions("resume:interviewlog:findByinvitationId")
    public R findByinvitationId(@PathVariable Integer id){
        InterviewLogEntity  obj = interviewLogService.findByinvitationId(id);

        return R.ok().put("obj",obj);
    }


}
